import './style/xiugaidenglumima.css';
import React from 'react';
import Navbar from '../component/Navbar';

import { Toast } from 'antd-mobile';

class XiuGaiDengLuMiMa extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            oldPassword: null,
            newPassword: null,
            threePassword: null,
        }
        this.data = this.props.location.query ? this.props.location.query.type : null;
    }
    switch() {
        const { oldPassword, newPassword, threePassword } = this.state
        if (!oldPassword) {
            Toast.info('请输入旧密码', 1.5);
            return
        }
        if (!newPassword) {
            Toast.info('请输入新密码', 1.5);
            return
        }
        if (!threePassword) {
            Toast.info('请确认密码', 1.5);
            return
        }

    }
    goBack = () => {
        this.props.history.goBack();
    }
    getOldPassword(e) {
        this.setState({ oldPassword: e.target.value })
    }
    getNewPassword(e) {
        this.setState({ newPassword: e.target.value })
    }
    getThreePassword(e) {
        this.setState({ threePassword: e.target.value })
    }
    render() {
        const { oldPassword, newPassword, threePassword } = this.state
        return (<div className='xiugaidenglumima'>
            <Navbar onClick={this.goBack} title={this.data === 1 ? '修改登录密码' : '修改提现密码'} rightText='确定' rightTextClick={() => this.switch()}></Navbar>
            <div className='main'>
                <div className='content'>
                    <div>旧密码</div>
                    <input value={oldPassword} onChange={this.getOldPassword.bind(this)} placeholder='请输入旧密码'></input>
                </div>
                <div className='content'>
                    <div>新密码</div>
                    <input value={newPassword} onChange={this.getNewPassword.bind(this)} placeholder='请输入新密码'></input>
                </div>
                <div className='content'>
                    <div>确认密码</div>
                    <input value={threePassword} onChange={this.getThreePassword.bind(this)} placeholder='请确认密码'></input>
                </div>
            </div>
        </div>)
    }
}

export default XiuGaiDengLuMiMa;